<%@page import="com.alibaba.fastjson.JSONObject"%>
<%@page import="com.meila.cms.util.config.Property"%>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="el"  uri="toJson.com/el-common" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"  %>
<%@ taglib prefix="c"   uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE HTML>
<html lang="zh-CN">
  <head>
    
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    
    <title>零部件库</title>

	<%@ include file="../common/common.jsp"%>
	<link href="resources/css/system/carDesign/design.css" rel="stylesheet"></link>
    
  </head>
  
  <body class="client-body">
  		<jsp:include page="../common/design-head2.jsp"></jsp:include>
  		
  		<script src="resources/js/system/partsDesign/designCommon.js"></script>
	  	<script src="resources/js/system/partsDesign/designParts.js"></script>
  		<!-- 左 -->
  		<div class="design-body design-bodyLeft">
			<div class="design-leftTag">零部件选择</div>
			
			<div class="pdm-searchBox clearfix">
				<select class="left" id="carid" name="carid">
		        </select>
		        <input class="form-control left" type="search" name="partsName" id="partsname"/>
		        <input type="hidden" class="form-control" name="partsType" id="partstype">
		        <a href="javascript:getPartListBySearch();"><i class="fa fa-search" ></i></a>
				</div>
			   
			<div class="design-leftmenu fontBox clearfix">
				<c:forEach var="dict" items="${partTypeList}">
				    <a class="a-black ${partsDesignModel.partsType==dict.value? 'activeFont':''}" href="javascript:getPartList('${dict.value}','','')">${dict.name}</a>
				 </c:forEach>
			</div>
			
			<div class="left-twoImgList listImgBox">
				<c:forEach var="parts" items="${partList}">
					<div class="left-twoImgBlock leftImgBlock ${parts.id==partsDesignModel.partsNo? 'activeImg':''}">
						<div class="left-twoImgBox"><img src="<%=Property.getProperty("FILESERVER_PATH") %>?id=${parts.physicalmap}"/></div>
						<div class="left-oneImgName">${parts.partsName}</div>
						<c:if test="${not empty parts.programmeid||not empty parts.productid||not empty parts.modleid}">
							<div class="left-imgSign">图纸</div>
						</c:if>
						<input type="hidden" value="${el:toJsonString(parts)}">
					</div>
				</c:forEach>
			</div>
		</div>
  		
  		<!-- 中 -->
  		<div class="design-body design-bodyMiddle">
  			<div class="design-btnBox btnBox clearfix">
				<a class="a-black activeBtn" href="javascript:pingmian()">平面</a>
			</div>
			
  			<div class="design-btnBox btnBox clearfix">
				<a class="a-black activeBtn" href="javascript:biancheng()">编程图</a>
				<a class="a-black" href="javascript:chanpin()">产品制作图</a>
				<a class="a-black" href="javascript:moju()">模具图</a>
			</div>
			
			<div class="design-middleActions">
				<a class="a-white activeBtn" href="javascript:;"><i class="fa fa-arrow-right"></i></a>
				<a class="a-white" href="javascript:showDownloadModal();"><i class="fa fa-download"></i></a>
				<a class="a-white" href="javascript:location.reload();"><i class="fa fa-refresh"></i></a>
			</div>
			
			<div class="middle-towImgList clearfix">
				<a class="middle-oneImgBox" href="front/partDesign/myPartDesignModify"><img id="twoDid_img"/></a>
			</div>
  		</div>
  		
  		<!-- 右 -->
  		<div class="design-body design-bodyRight">
			<div class="design-leftTag">细节设置</div>
			
			<div class="design-rightForm pdm-rightForm">
				<form class="form-horizontal" id="partDesignform">
				   <div class="rightFormUp"> 
				   		<div class="form-group">
						    <label class="col-sm-4 control-label">零件号</label>
						    <div class="col-sm-8">
						      <input id="partsNo" name="partsNo" type="text" class="form-control" value="${partsDesignModel.partsNo}"/>
						      <input id="id" name="id" type="hidden" class="form-control" value="${partsDesignModel.id}"/>
						      <input id="twoDid" name="twoDid" type="hidden" class="form-control" value="${partsDesignModel.twoDid}"/>
						      <input id="threeDid" name="threeDid" type="hidden" class="form-control" value="${partsDesignModel.threeDid}"/>
						      <input id="programmeid" name="programmeid" type="hidden" class="form-control" value="${partsDesignModel.programmeid}"/>
						      <input id="productid" name="productid" type="hidden" class="form-control" value="${partsDesignModel.productid}"/>
						      <input id="modleid" name="modleid" type="hidden" class="form-control" value="${partsDesignModel.modleid}"/>
						      <input id="car" name="car" type="hidden" class="form-control" value="${partsDesignModel.carid}"/>
						      <input id="status" name="status" type="hidden" class="form-control" value="${partsDesignModel.status}"/>
						      <input id="partsType" name="partsType" type="hidden" class="form-control" value="${partsDesignModel.partsType}"/>
						      <input id="modifier" name="modifier" type="hidden" class="form-control" value="${partsDesignModel.modifier}"/>
						      <input id="physicalmap" name="physicalmap" type="hidden" class="form-control" value="${partsDesignModel.physicalmap}">
						    </div>
						  </div>
						  
						  <div class="form-group">
						    <label class="col-sm-4 control-label">零件名</label>
						    <div class="col-sm-8">
						      <input id="partsName" name="partsName" type="text" class="form-control" value="${partsDesignModel.partsName}"/>
						    </div>
						  </div>
						  
						  <div class="form-group">
						    <label class="col-sm-4 control-label">材料</label>
						    <div class="col-sm-8">
						      <input id="material" name="material" type="text" class="form-control" value="${partsDesignModel.material}"/>
						    </div>
						  </div>
						  
						  <div class="form-group">
						    <label class="col-sm-4 control-label">备注</label>
						    <div class="col-sm-8">
						      <textarea id="comment" name="comment">${partsDesignModel.comment}</textarea>
						    </div>
						  </div>
				   </div><!-- rightFormUp -->
				 	
				 	<div id="property" class="rightFormDown">
				 		<c:forEach varStatus="status" var="property" items="${propertyList}">
				 			<div class="form-group">
				 				<label class="col-sm-4 control-label">${property.propertyName}</label>
				 				<div class="col-sm-8">
				 					<input type="hidden" name="partsid" class="form-control" value="${property.partsid}"/>
						      		<input type="number" id="${status.count}" name="propertyValue" class="form-control" value="${property.propertyValue}"/>
						    	</div>
				 			</div>
				 		</c:forEach>
				 	</div><!-- rightFormDown -->
				 	
			        <div class="form-group">
					    <div class="col-sm-12 rightForm-footBtn">
				            <a class="btn btn2 a-white" href="javascript:this.location.reload()">重置</a>
				            <a class="btn btn2 right a-white" href="javascript:submitForm('${param.designame}')">保存修改</a>
					    </div>
				    </div>
				</form>
			</div>
		</div>
  	
  	<!-- 下载modal -->
	<div class="modal fade bs-example-modal-sm" id="loadModal" tabindex="-1" role="dialog" aria-labelledby="loadModalLabel" data-backdrop="static">
	  <div class="modal-dialog modal-sm" role="document">
	    <form action="front/partDesign/downloadFileBychoseFromParts" method="post" id="downloadForm">
		    <div class="modal-content">
		      <div class="modal-header">
		        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
		        <h4 class="modal-title">请选择所需文档</h4>
		      </div>
		      
		      <div class="modal-body load-modalBody clearfix">
		        <input name="designid"  id="designid" type="hidden" value=""/> 
		        <label><input name="chose" type="checkbox" value="1" /> 2D文档 </label>
		        <label><input name="chose" type="checkbox" value="2" /> 3D文档 </label>
				<label><input name="chose" type="checkbox" value="3" /> 编程图 </label>
				<label><input name="chose" type="checkbox" value="4" /> 产品制作图 </label>
				<label><input name="chose" type="checkbox" value="5" /> 模具图 </label>
		      </div>
		      
		      <div class="modal-footer">
		      	<button type="button" class="btn btn1" onclick="submitDownload()">确定下载</button>
		        <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
		      </div>
		    </div>
	     </form>
	  </div>
	</div>
		
  	<!-- Modal -->
	<div class="modal fade" id="partModifyModal" tabindex="-1" role="dialog" aria-labelledby="partModifyModalLabel" data-backdrop="static">
	  <div class="modal-dialog modal-sm">
	    <form action="">
		    <div class="modal-content">
		      
		      <div class="modal-body">
				  <div class="carModal-body">
				    <i class="fa fa-check-circle"></i>
				    <span>您已保存成功！</span>
				  </div>
		      </div>
		      
		      <div class="modal-footer carModal-footer">
		        <button type="button" class="btn btn-default" data-dismiss="modal" onclick="shutdown()">关闭</button>
		        <%-- <button type="submit" class="btn btn2 a-white" onclick="submitForm('${param.designname}')">保存并退出</button> --%>
		      </div>
		      
		    </div>
	     </form>
	  </div>
	</div>
    <script type="text/javascript">
        	$.ajax({  
	        type : "POST",  
	        url : CONTEXT_PATH+'common/selectByComboCategory?category=CarType',  
	        dataType : "json",  

	        success : function(data) {  
 
	            var optionStr = '';  
	            for (var i = 0; i < data.length; i++) {  
                    if('${partsDesignModel.carid}'==data[i].value){
                          optionStr += "<option selected value="+data[i].value+">"+data[i].text+"</option>";  
                    }else{
                          optionStr += "<option value="+data[i].value+">"+data[i].text+"</option>"; 
                    }
	                 
	            }  
	            $("#carid").html("<option value=''>全部</option>" + optionStr);  
	        }  
	    });
	    
	    var pingmian=function(){
	    	var twoDid=$("#twoDid").val();
	    	if(twoDid==''){
	    		alert("请选择您要下载的零件！");
	    	}else{
	    		window.location.href='<%=Property.getProperty("FILESERVER_PATH_DOWN") %>?id='+twoDid;
	    	}
	    };
	    
	    var biancheng=function(){
	    	var programmeid=$("#programmeid").val();
	    	if(programmeid==''){
	    		alert("请选择您要下载的零件！");
	    	}else{
	    		window.location.href='<%=Property.getProperty("FILESERVER_PATH_DOWN") %>?id='+programmeid;
	    	}
	    };
	    
	    var chanpin=function(){
	    	var productid=$("#productid").val();
	    	if(productid==''){
	    		alert("请选择您要下载的零件！");
	    	}else{
	    		window.location.href='<%=Property.getProperty("FILESERVER_PATH_DOWN") %>?id='+productid;
	    	}
	    };
	    
	    var moju=function(){
	    	var modleid=$("#modleid").val();
	    	if(modleid==''){
	    		alert("请选择您要下载的零件！");
	    	}else{
	    		window.location.href='<%=Property.getProperty("FILESERVER_PATH_DOWN") %>?id='+modleid;
	    	}
	    };
	    
	    var showDownloadModal=function(){
	    	var id=$("#id").val();
	    	if(id==''){
	    		alert("请选择您要下载的零件！");
	    	}else{
	    		download(id);
	    	}
	    };
	    
	    var getPartListBySearch=function(){
	    	var partstype=$("#partstype").val();
	    	var carid=$("#carid").val();
	    	var partsName=$("#partsname").val();
	    	
	    	getPartList(partstype,partsName,carid);
	    };
	    
	    var shutdown=function(){
	    	window.location.href="front/partDesign/myPartDesignModify";
	    };
	    
    	function sandi(){
    		$("#threeDid_img").attr('src',FILESERVER_PATH+"?id="+'${partsDesignModel.threeDid}');
    	}
    	if('${partsDesignModel.twoDid}'!=''){
    		$("#twoDid_img").attr('src',FILESERVER_PATH+"?id="+'${partsDesignModel.twoDid}');
    	}

    </script>
  </body>
</html>
